package com.oz.entity;

import java.sql.Timestamp;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Table;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

@Table(appliesTo = "basic_user", comment = "基础用户")
@Entity(name = "basic_user")
@TableName(value = "basic_user")
public class UserEntity {

	@Id
	@Column(length = 32)
	private String id;

	@Comment("姓名") // 姓名
	@Column(length = 16)
	private String username;

	@Comment("登录密码")
	@Column(length = 64)
	private String password;

	@Comment("头像") // 头像
	@Column(length = 128)
	private String headimg;

	@Transient
	@TableField(exist = false)
	@Comment("权限") // 权限
	@ManyToMany
	@JoinTable(name = "user_role", joinColumns = {
			@JoinColumn(name = "user_id", referencedColumnName = "id") }, inverseJoinColumns = {
					@JoinColumn(name = "role_id", referencedColumnName = "id") })
	List<RoleEntity> roles;

	@Comment("是否激活可用") // 是否激活可用
	private boolean enabled;

	@Comment("电话")
	@Column(length = 64, unique = true)
	private String phone;

	@Comment("详细送货地址") // 详细送货地址
	@Column(length = 128)
	private String address;

	@Comment("生日") // 生日
	private Timestamp birth;

	// 该用户上传的文章
	@Transient
	@TableField(exist = false)
	@OneToMany
//	@TableField(exist = false)
	List<MediaEntity> media;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getHeadimg() {
		return headimg;
	}

	public void setHeadimg(String headimg) {
		this.headimg = headimg;
	}

	public List<RoleEntity> getRoles() {
		return roles;
	}

	public void setRoles(List<RoleEntity> roles) {
		this.roles = roles;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Timestamp getBirth() {
		return birth;
	}

	public void setBirth(Timestamp birth) {
		this.birth = birth;
	}

	public List<MediaEntity> getMedia() {
		return media;
	}

	public void setMedia(List<MediaEntity> media) {
		this.media = media;
	}

}
